#include "ServiceChoose.h"
#include "ui_servicechoose.h"
#include "QDebug"
#include "QMessageBox"
#include "globalParameterForTaxi.h"


interface::CServiceChooseInterface::CServiceChooseInterface(IInterface *parent)
    :IInterface(parent),
      m_pUi(new Ui::ServiceChoose())
{
    m_pUi->setupUi(this);

    // setup the background
    this->UiSetting(m_pUi);

    // connect between buttons and actions
    connect(m_pUi->btnBeginBusiness, SIGNAL(clicked()), this, SLOT(bntClicked()) );
    connect(m_pUi->btnIntelligentGuide, SIGNAL(clicked()), this, SLOT(bntClicked()) );
    connect(m_pUi->btnCustomerServices, SIGNAL(clicked()), this, SLOT(bntClicked()) );
    connect(m_pUi->btnFixLocationCallCar, SIGNAL(clicked()), this, SLOT(bntClicked()) );
    connect(m_pUi->btnLandscapeSearch, SIGNAL(clicked()), this, SLOT(bntClicked()) );
    connect(m_pUi->btnRountinSearch, SIGNAL(clicked()), this, SLOT(bntClicked()) );
}

interface::CServiceChooseInterface::~CServiceChooseInterface()
{
    delete m_pUi;
}

void interface::CServiceChooseInterface::UiSetting(Ui::ServiceChoose *ui)
{
    //setup the background
    IInterface::SetupBackground(QString("images\\background.jpg"));

    //setup the guide button
    IInterface::SetupBtn(ui->btnIntelligentGuide, QString("images\\ChooseService\\guide.png"));

    //setup the begin business button
    IInterface::SetupBtn(ui->btnBeginBusiness, QString("images\\ChooseService\\beginbusiness.png"));

    //setup the fix location calling car button
    IInterface::SetupBtn(ui->btnFixLocationCallCar, QString("images\\ChooseService\\FixedCallingPlace.png"));

    //setup the routin search button
    IInterface::SetupBtn(ui->btnRountinSearch, QString("images\\ChooseService\\RoutineSearch.png"));

    //setup the landscape button
    IInterface::SetupBtn(ui->btnLandscapeSearch, QString("images\\ChooseService\\LandScape.png"));

    //setup the customer service button
    IInterface::SetupBtn(ui->btnCustomerServices, QString("images\\ChooseService\\CustomerService.png"));
}

void interface::CServiceChooseInterface::bntClicked()
{
    QPushButton *pushedBtn = (QPushButton*)(QObject::sender());

    int to = 0;
    if (pushedBtn == m_pUi->btnBeginBusiness)
    {
        to = interface::CHOOSE_CLIENT;
    }
    else if (pushedBtn == m_pUi->btnIntelligentGuide)
    {
        to = interface::INTELLIGENT_GUIDE;
    }
    else if (pushedBtn == m_pUi->btnCustomerServices)
    {
        to = interface::CUSTOMER_SERVICES;
    }
    else if (pushedBtn == m_pUi->btnFixLocationCallCar)
    {
        to = interface::FIXED_LOCATION_CALL_CAR;
    }
    else if (pushedBtn == m_pUi->btnLandscapeSearch)
    {
        to = interface::LANDSCAPE_SEARCH;
    }
    else if (pushedBtn == m_pUi->btnRountinSearch)
    {
        to = interface::ROUNTIN_SEARCH;
    }

    // send out the request to change interface
    emit changeInterfaces(interface::SERVICE_CHOOSE, (interface::InterfaceRequestEnum)to, NULL);
}
